import tensorflow as tf
from tensorflow.python.platform import gfile
import os
def convert_pb_to_pbtxt(filename):
    prefix = filename[:-3]
    pbtxt=prefix+".pbtxt"
    targetdir="/hadoop/station_photo_determine/model/newmodel/pb_model"
    with gfile.FastGFile(filename,'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        tf.import_graph_def(graph_def, name='')
        tf.train.write_graph(graph_def, targetdir, pbtxt, as_text=True)
    return
pbf="/hadoop/station_photo_determine/model/newmodel/pb_model/ws3_keras_mobile_model_1107_no_tl.pb"
convert_pb_to_pbtxt(pbf)
